import request from "@/utils/request"

// 获取字段映射关系
export function getOption(params) {
  return request({
    url: `/v1/base/get-option`,
    method: "get",
    params,
  })
}

// 获取操作日志
export function log(params) {
  return request({
    url: `/v1/base/log`,
    method: "get",
    params,
  })
}
// 获取租户组织架构
export function organizationList(data) {
  return request({
    baseURL: window.APP_GETEWAY.auth,
    url: "/tenant/organization",
    method: "post",
    data,
  })
}

/**
 * http://10.20.9.32:40001/project/57/interface/api/4935
 * @param data
 * @returns {*}
 */
export function tmsOverallOptions(data) {
  return request({
    baseURL: window.APP_GETEWAY.tms,
    url: "/options",
    method: "post",
    data,
  })
}

/**
 * 按条件获取渠道
 * http://10.20.9.32:40001/project/61/interface/api/13835
 * @param data
 * @returns {*}
 */
export function apiGetChannel(data) {
  return request({
    baseURL: window.APP_GETEWAY.tms,
    url: "/opts/channel",
    method: "post",
    data,
  })
}

export function apiTmsEnum(data) {
  return request({
    baseURL: window.APP_GETEWAY.tms,
    url: "/opts",
    method: "post",
    data,
  })
}

/**
 * 仓库属性枚举
 */
export function apiGetWarehouseEnum(params) {
  return request({
    baseURL: window.APP_GETEWAY.wms,
    url: "/api/warehouse-enum",
    method: "get",
    params,
  })
}

/**
 * 获取仓库列表
 * http://10.20.9.32:40001/project/65/interface/api/6825
 */
export function apiGetWarehouseList(data) {
  return request({
    baseURL: window.APP_GETEWAY.wms,
    url: "/api/warehouse-list",
    method: "post",
    data,
  })
}

//获取下拉选项数据
export function overallOptions(data) {
  return request({
    url: "/options",
    method: "post",
    data,
  })
}

/**
 * http://10.20.9.32:40001/project/61/interface/api/13835
 * @param data
 * @returns {*}
 */
export function apiGetOptsChannel(data) {
  return request({
    baseURL: window.APP_GETEWAY.tms,
    url: "/opts/channel",
    method: "post",
    data,
  })
}

// goods 获取枚举列
export function goodsBaseGetEnums(data) {
  return request({
    baseURL: window.APP_GETEWAY.goods,
    url: "/base/get-enums",
    method: "post",
    data,
  })
}

export const getPlatforms = (params) => {
  return request({
    baseURL: window.APP_GETEWAY.goods,
    url: "/v1/platform/tree",
    method: "get",
    params,
  })
}

export const getOrcdxq = (params) => {
  return request({
    baseURL: window.APP_GETEWAY.tms,
    url: "/order/order-track/detail",
    method: "get",
    params,
  })
}

export const getPlatformOptions = (params) => {
  return request({
    baseURL: window.APP_GETEWAY.base,
    url: "/v1/platform/platforms",
    method: "get",
    params,
  })
}

export const getSiteOptions = (params) => {
  return request({
    baseURL: window.APP_GETEWAY.base,
    url: "/v1/platform/sites",
    method: "get",
    params,
  })
}

export const getShopOptions = (data) => {
  return request({
    baseURL: window.APP_GETEWAY.base,
    url: "/v1/shop/drop-list",
    method: "POST",
    data,
  })
}

/**
 * 运输方式
 * @param data
 * @returns {*}
 */
export const apiGetShippingMethods = (data = { is_option: true }) => {
  return request({
    baseURL: window.APP_GETEWAY.tms,
    url: "/internal/channel/get-transport-type",
    method: "post",
    data,
  })
}

/**
 * 运输方式
 * @param params
 * @returns {*}
 */
export const apiGetLogisticsPreferredStrategy = (params = {}) => {
  return request({
    url: "/base/order-strategy/rule-name",
    method: "get",
    params,
  })
}

// 获取店铺下拉列表
export const getShop = (data) => {
  return request({
    baseURL: window.APP_GETEWAY.base,
    url: "/v1/shop/drop-list",
    method: "post",
    data,
  })
}

export const apiGetPlatformSites = (params) => {
  return request({
    baseURL: window.APP_GETEWAY.base,
    url: "/v1/platform/sites",
    method: "get",
    params,
  })
}

// 获取平台列表
export const apiGetPlatform = (params) => {
  return request({
    baseURL: window.APP_GETEWAY.base,
    url: "/v1/platform/tree",
    method: "get",
    params,
  })
}

// 获取国家列表
export const getCountry = (params) => {
  return request({
    baseURL: window.APP_GETEWAY.goods,
    url: "/api/goods/get-countrys",
    method: "get",
    params,
  })
}

// 获取国家option 别名+中文
export const getCountryOption = (params) => {
  return request({
    baseURL: window.APP_GETEWAY.goods,
    url: "/api/goods/get-country-lable",
    method: "get",
    params,
  })
}

// 根据sku获取渠道sku 列表
export const getChannelSku = (data) => {
  return request({
    baseURL: window.APP_GETEWAY.goods,
    url: "/api/get-channel-sku-list",
    method: "post",
    data,
  })
}

// 获取业务日志
export const getBusinessLog = (params) => {
  return request({
    url: "/log/business",
    method: "get",
    params,
  })
}

// 币种
export function getCurrency(params) {
  return request({
    baseURL: window.APP_GETEWAY.goods,
    url: "/api/goods/get-currency",
    method: "get",
    params,
  })
}

// 商品SkU列表
export function getGoodsSkuList(data) {
  return request({
    baseURL: window.APP_GETEWAY.goods,
    url: "/v1/goods/sku/list",
    method: "post",
    data,
  })
}
// 商品物流属性
export function getLogisticsAttributes(params) {
  return request({
    baseURL: window.APP_GETEWAY.goods,
    url: "/api/goods/get-logistics-attributes",
    method: "get",
    params,
  })
}

// 获取仓库option
export const getWarehouseOptions = (params = { status: 1 }) => {
  return request({
    baseURL: window.APP_GETEWAY.wms,
    url: "/api/warehouse-option",
    method: "get",
    params,
  })
}

// 获取仓库信息
export const getWarehouseList = (data) => {
  return request({
    baseURL: window.APP_GETEWAY.wms,
    url: "/api/warehouse-list",
    method: "post",
    data,
  })
}

// 文件上传签名
export const uploadSignUrl = (params) =>
  request({
    url: "/file/signUrl",
    method: "get",
    params,
  })

/**
 * 获取仓库库存
 * @param data
 * @returns {*}
 * http://10.20.9.32:40001/project/65/interface/api/14120
 */
export const apiGetWarehouseInventoryList = (data) =>
  request({
    baseURL: window.APP_GETEWAY.wms,
    url: "/api/warehouse-inventory-list",
    method: "post",
    data,
  })
// 货主库存
export const skuOwnerInventory = (data) =>
  request({
    baseURL: window.APP_GETEWAY.wms,
    url: "/api/sku-owner-inventory",
    method: "post",
    data,
  })

// 文件上传签名
export const getWarehouseEnum = (params) =>
  request({
    baseURL: window.APP_GETEWAY.wms,
    url: "/api/warehouse-enum",
    method: "get",
    params,
  })

// 运费试算
export const feeTrialCalcFreight = (data) =>
  request({
    baseURL: window.APP_GETEWAY.tms,
    url: "/fee/trial-calc/freight",
    method: "post",
    data,
  })
// 物流订单-获取订单申报信息
export const getDeclareInfo = (data) =>
  request({
    baseURL: window.APP_GETEWAY.tms,
    url: "/order/order/get-declare-info",
    method: "post",
    data,
  })

// 获取分类列表
export function classify(params) {
  return request({
    baseURL: window.APP_GETEWAY.goods,
    url: "/base/backend-classification/get-list",
    method: "get",
    params,
  }).then((res) => res.data)
}

// 部门
export function department(params) {
  return request({
    baseURL: window.APP_GETEWAY.auth,
    url: "/department",
    method: "get",
    params,
  }).then((res) => res.data)
}
// 员工
export function personnel(params) {
  return request({
    baseURL: window.APP_GETEWAY.auth,
    url: "/tenant/organization",
    method: "get",
    params,
  }).then((res) => res.data)
}
// 获取 平台运输方式
export const getShippingService = (params) =>
  request({
    url: "/base/shipping-service",
    method: "get",
    params,
  })
